﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.Training;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.Training
{
    public class TrainingContentService: IService<TrainingContent>
    {
        private readonly GenericRepository<TrainingContent> _trainingContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public TrainingContentService(IUnitOfWork unitOfWork, GenericRepository<TrainingContent> trainingContentRepository)
        {
            this._trainingContentRepository = trainingContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<TrainingContent> GetAllElements()
        {
            return _trainingContentRepository.GetAll();
        }

        public TrainingContent GetElementById(int id)
        {
            return _trainingContentRepository.GetById(id);
        }

        public void CreateElement(TrainingContent entity)
        {
            _trainingContentRepository.Insert(entity);
        }

        public void UpdateElement(TrainingContent entity)
        {
            _trainingContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _trainingContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
